/* 删除通用 */
$("._del").click(function () {
    var othis = $(this);
    var id = othis.attr("attr-id");
    var url = othis.attr("attr-url");
	var info=othis.attr("title");
	if(!info){
		info="你确定要删除吗？";
	}
    if (!id || !url) {
        layer.msg('参数有误!');
    }
    layer.confirm(info, {icon: 3}, function (index) {
        $.post(url, {id: id},
            function (data) {
                layer.close(index);
                if (data.code == 1) {
                    othis.parents('tr').fadeOut("normal", function () {
                        othis.remove();
                    });
                } else {
                    layer.msg(data.msg);
                }
            });
    });
});
/* 改变状态通用 */
$("._set_status").click(function () {
    var othis = $(this);
    var id = othis.attr("attr-id");
    var url = othis.attr("attr-url");
    if (!id || !url) {
        layer.msg('参数有误!');
    }
    $.post(url, {id: id},
        function (data) {
            if (data.code == 1) {
                layer.msg(data.msg, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function () {
                    //do something
                    location.reload();
                });
            } else {
                layer.msg(data.msg);
            }
        });
});
/* 表单提交 */
$('#myform').ajaxForm({
    success: complete, // 这是提交后的方法
    dataType: 'json'
});

function complete(data) {
    if (data.code == 1) {
        layer.alert(data.msg, {icon: 6}, function (index) {
            layer.close(index);
            window.location.href = data.url;
        });
    } else {
        layer.msg(data.msg);
        return false;
    }
}
/*全选*/
function CheckAll(form){
    for (var i=0;i<form.elements.length;i++){
        var e = form.elements[i];
        if (e.Name != 'chkAll'&&e.disabled==false)
            e.checked = form.chkAll.checked;
    }
}